#pragma once
#include "IData.h"
#include "ODBCHandler.h"
#include "../Config/DatabaseConfig.h"

class HanaData : public IData
{
public:
    HanaData(const DatabaseConfig &database_config);
    virtual ~HanaData();

	virtual int num_rows(const std::string &table) override;

    virtual bool select(const std::string &sql, Fields &fields, int &num_rows, std::vector<Field> *columns) override;

    virtual bool select(const std::string &sql, const std::vector<std::string> &args, Fields &fields, int &num_rows, std::vector<Field> *columns) override;

    bool select_sync(const std::string &sql, const std::vector<Field> &columns, char *values, int &num_rows);

    virtual bool insert(const std::string &table, Fields &fields, int num_rows, std::vector<Field> &columns) override;

    bool insert_sync(const std::string &table, Fields &fields, int num_rows, std::vector<Field> &columns);

	virtual bool isDatabaseExists(const std::string &database) override;

	virtual int createDatabase(const std::string &database) override;

	virtual int useDatabase(const std::string &database) override;

	virtual bool isTableExists(const std::string &table) override;

    virtual int createTable(const std::string &table, std::vector<Field> &columns) override;

    int createTable_sync(const std::string &table, std::vector<Field> &columns);

    virtual int showTables(std::vector<std::string> &tables) override;

    virtual int showColumns(const std::string &table, std::vector<Field> &columns) override;

    inline void logError(ODBCHandler &handler, int line);

protected:
    bool getData(ODBCHandler &hstmt, Fields &fields, int &num_rows, std::vector<Field> *columns);

public:
    ODBCHandler *hdbc_ = nullptr;

	DatabaseConfig database_config_;
};

